var baseUrl = 'http://106.12.80.17:9191/';
function request(params, callback) {
  var content_type='application/json';
  if (!params.method) {
    params.method = 'GET';
  }
  if (params.method == 'GET') content_type = 'application/json'
  else if (params.method == 'POST') content_type = 'application/x-www-form-urlencoded'
  $.ajax({
    headers: {
      Token: "pcl1jpfrYBgCdfTWeJvgsDz0MXuFONY6OIwA3PkpPDv4NSASbpUbjzBAW9E4XlMQ3MGkKvvkBA/xozH2hWbqeHEcf+WeOKQBmajshVGpMc50FZQ85AuA3w=="
    },
    content_type:content_type,
    url: baseUrl + params.url,
    type: params.method,
    data: params.data,
    success(res) {
      callback && callback(res);
    },
    error(err) {
      console.log(err)
    }
  })
}
//判断手机号码是否注册
function judgeMobile(data,callBack){
	var param={
	  url:'/index/auth/judgeMobile',
	  method:'POST',
	  data:data
	}
	request(param,function(res){
	  callBack(res);
	})
}
//注册
function register(data,callBack){
	var param={
	  url:'/index/auth/register',
	  method:'POST',
	  data:data
	}
	request(param,function(res){
	  callBack && callBack(res);
	})
}
//登录（手机号码+密码）
function login(data,callBack){
	data.device='web';
	var param={
	  url:'/index/auth/login',
	  method:'POST',
	  data:data
	}
	request(param,function(res){
	  callBack && callBack(res);
	})
}
//登录（手机号+验证码）
function loginCode(data,callBack){
	var param={
	  url:'index/auth/loginCode',
	  method:'POST',
	  data:data
	}
	request(param,function(res){
	  callBack && callBack(res);
	})
}
//获取验证码
function getCaptcha(data,callBack){
	 var param={
	  url:'index/auth/getCaptcha',
	  method:'POST',
		data:data
	}
	request(param,function(res){
	  callBack && callBack(res);
	})
}
//校验验证码
function verifyCaptcha(data,callBack){
	var param={
	  url:'index/auth/verifyCaptcha',
	  method:'POST',
		data:data
	}
	request(param,function(res){
	  callBack && callBack(res);
	})
}
//获取一级和二级分类-首次登陆使用
function getIndexCourseTypeList(callBack){
  var param={
    url:'/courseType/getIndexCourseTypeList',
    method:'POST',
  }
  request(param,function(res){
    callBack && callBack(res);
  })
}
//获取一级分类
function getOneCourseTypeList(callBack){
  var param={
    url:'/courseType/getOneCourseTypeList',
    method:'POST',
  }
  request(param,function(res){
    callBack && callBack(res);
  })
}


//首页获取轮播图
function getCarouselList(callBack){
  var param={
    url:'home/getCarouselList',
    method:'POST',
  }
  request(param,function(res){
    callBack(res);
  })
}
//获取课程分页
function getCoursePage(data,callBack){
  data=data||{type:1};
  var param={
    url:'home/getCoursePage',
    method:'POST',
    data:data
  }
  request(param,function(res){
    callBack(res);
  })
};
//获取正在直播列表
function getLiveCourseList(callBack){
	var param={
		url:"home/getLiveCourseList",
		method:"POST"
	}
	request(param,function(res){
		 callBack(res);
	})
};
//推荐老师
function getTeacherPage(data,callBack){
  var param={
    url:'home/getTeacherPage',
    method:'POST',
    data:data
  }
  request(param,function(res){
    callBack(res);
  })
};

//baseAppUser/auditEdit个人入驻申请 
function auditEdit(data,callBack){
  var param={
    url:'baseAppUser/auditEdit',
    method:'POST',
    data:data
  }
  request(param,function(res){
    callBac&&callBack(res);
  })
};



